home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
harderr.arc
/
NOWAY.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-10-12
|
7KB
|
179 lines
; Program Name : noway.asm
; Author : bill buckels
; Date : July 26, 1991
; Function : tsr program to disable CONTROL C and CONTROL BREAK
kb_data equ 60h ;keyboard data port
kb_ctrl equ 61h ;keyboard control port
eoi equ 20h ;8259 end-of-interrupt value
int_ctrl_port equ 20h ;8259 PIC port
c_key equ 2Eh ;scan code for 'C' key
ctrl_key equ 4 ;shift code for Ctrl key
cr equ 0dh ;carriage return
lf equ 0ah ;line feed
CODE SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CODE
ORG 100h
BEGIN: jmp INITIALIZE ;jump to initialization code
old_int_9h label dword ;old keyboard interrupt vector
old_keyboard_int dw 2 dup (?)
;-------------------------------------------------------
;NO_CTRL_C resident mainline and
;Front-end routine for the keyboard interrupt handler.
;Execution is vectored here whenever an interrupt 9
;is generated by the keyboard.
;-------------------------------------------------------
NO_CTRL_C PROC NEAR
sti ;enable interrupts
push ax ;save registers
push bx
push cx
push dx
push si
push di
push ds
push es
in al,kb_data ;get scan code from keyboard
cmp al,c_key ;was the 'C' key pressed?
je HOT_C ;yes...
jne EXIT ;no, then exit to normal routine
HOT_C:
mov ah,2 ;get state of shift keys
int 16h
test al,ctrl_key ;is the CTRL key depressed?
jne IGNORE ;yes, then continue
;Exit is achieved thru here when execution is to be transferred
;to the normal
;BIOS keyboard interrupt handling routine.
EXIT: pop es ;restore registers
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
jmp old_int_9h ;goto BIOS keyboard routine
;The key combination CTRL-C was just pressed.
;Reset the keyboard and issue an
;EOI to the 8259 PIC to enable hardware interrupts.
IGNORE: call kb_reset ;reset keyboard, end 8259 int
pop es ;restore register values for exit
pop ds
pop di
pop si
pop dx
pop cx
pop bx
pop ax
iret ;return to interrupted program
NO_CTRL_C ENDP
;-------------------------------------------------------------------
;KB_RESET resets the keyboard and issues an EOI (end of interrupt)
;to the 8259 PIC.
;-------------------------------------------------------------------
kb_reset PROC NEAR
in al,kb_ctrl ;get current control port value
mov ah,al ;save it in AH
or al,80h ;set bit 7
out kb_ctrl,al ;send reset value
mov al,ah ;get original value
out kb_ctrl,al ;send it out to enable keyboard
cli ;suspend interrupts
mov al,eoi ;get EOI value
out int_ctrl_port,al ;send EOI to 8259
sti ;enable interrupts
ret
kb_reset ENDP
;-------------------------------------------------------
;routine for the CTRL-BREAK interrupt handler.
;Execution is vectored here whenever an interrupt 1Bh
;is generated.
;-------------------------------------------------------
NO_BREAK PROC NEAR
sti ;enable interrupts
iret ;return to interrupted program
NO_BREAK ENDP
;------------------------------------------------------------
; RESIDENT PORTION ENDS *** TRANSIENT PORTION STARTS
;------------------------------------------------------------
;------------------------------------------------------------
;initialization message
;------------------------------------------------------------
CREDIT$ db 'NOWAY(C) by Bill Buckels 1991',cr,lf
db 'CTRL BREAK and CTRL C are now disabled',cr,lf,'$'
;------------------------------------------------------------
;LIST$ writes a string to stdout
;------------------------------------------------------------
LIST$ PROC NEAR
push ax
mov ah,9h ; call dos function 9H
int 21h
pop ax
ret
LIST$ ENDP
;----------------------------------------------------------------
;INITIALIZE performs tasks to set the stage for the resident part
;of the program.
;-----------------------------------------------------------------
INITIALIZE PROC NEAR
;let them know who we are
lea dx, CREDIT$
call LIST$
;Now save the old interrupt 9 vector and replace it
;with one pointing to the
;code that we will leave behind in memory.
mov ah,35h ;get current interrupt 9 vector
mov al,9
int 21h
mov old_keyboard_int,bx ;save vector offset
mov old_keyboard_int[2],es ;save vector segment
mov ah,25h ;set new vector
mov al,9
lea dx,NO_CTRL_C ;point it to new handler
int 21h
;Next point the interrupt 1B vector to a null function
;that we will leave behind in memory.
mov ah,25h ;set new vector
mov al,1bh
lea dx,NO_BREAK ;point it to new handler
int 21h
;Exit thru INT 27h and reserve enough room
;the offset of CREDIT$ is a marker to end of resident code
mov dx,offset CREDIT$ ;reserve space for code
int 27h ;terminate-but-stay-resident
INITIALIZE ENDP
;
CODE ENDS
END BEGIN